package org.openharmony.qttool.components;

import org.openharmony.qttool.QtSDK;
import javax.swing.*;
import java.awt.*;

public class QtSDKListCellRenderer extends JLabel implements ListCellRenderer<QtSDK> {
    public QtSDKListCellRenderer() {
        setOpaque(true);
    }

    @Override
    public Component getListCellRendererComponent(JList<? extends QtSDK> list, QtSDK value, int index, boolean isSelected, boolean cellHasFocus) {
        if (value != null) {
            setText(value.version() + " (" + value.getArch() + ")");
        } else {
            setText("");
        }

        setBackground(isSelected ? list.getSelectionBackground() : list.getBackground());
        setForeground(isSelected ? list.getSelectionForeground() : list.getForeground());

        return this;
    }
}
